---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

## Replication Files for "Academic Freedom Growth and Decline Episodes" ##

Journal: Higher Education

DOI: 10.1007/s10734-023-01156-z

Link: https://doi.org/10.1007/s10734-023-01156-z

Author: Lars Lott

Correspondence: Lars Lott, Friedrich-Alexander-University Erlangen-Nürnberg (lars.lott@fau.de)

Date: December 13rd, 2023


Required Software: R and RStudio (4.2.3 or Above). 

Additional required software packages and libraries are specified in the replication code. 

#### Overview ####
These files replicate all analyses presented in “Academic Freedom Growth and Decline Episodes”, Higher Education https://doi.org/10.1007/s10734-023-01156-z

To replicate all analyses and figures, download all data files to a folder entitled “~/data”, create a second folder entitled “~/results” in the same directory, and run all code files
in numerical order. Create also a third folder named "~/figures" in the same directory to store all graphical outputs. In addition, you can use the Rproject file to automatically handle the file paths 

The article titled “Academic Freedom Growth and Decline Episodes” uses an episode approach to learn about academic freedom growth and decline episodes worldwide between 1900 and today. To produce these episode dataset, you can use the companion R package "EpisodeR" avaiable under https://github.com/LarsLott/EpisodeR.

#### Replication Code ####

01_generate_episodes_dataset.R
Repliactes the data wrangling process and esimates the main dataset including the *Academic Freedom Growth and Decline Episodes dataset*. Replicates Table 1 and Figure 1 to Figure 6. 

02_data_analysis.R
Replicates all main Diff-in-Diff regression analyses presented in the paper, including all Figures 6 to 9.

03_bfa.R
Replicates the data wrangling process and the Bayesian factor analysis (BFA) model to construct the four-item academic freedom index. The BFA model takes approximately 24 hours to converge.
A pre-processed data file named "academic_freedom_index_cy.rds" can be used for all other scripts. Then, user can skip running 03_bfa.R

04_appendix.R
Replicates all analyses as well as all robustness tests presented in Supplementary Appendix.

##### R Functions #####

All following R files are helper functions to get the *Academic Freedom Growth and Decline Episodes dataset* and are also part of the EpisodeR R Package available here: https://github.com/LarsLott/EpisodeR. These fucntions are loaded in the respective R-file when used. 
get_episode_function.R

get_episode_function_wo_CI.R

get_episode_function_wo_CI_four_item.R

plot_all_episode.R

plot_episodes_function.R

#### Data files (relative path "~/data") ####

Replication data: 
-bayes.academic_freedom_index_cd.rds: country-date four-item academic freedom index data
-bayes.academic_freedom_index_cy.rds: country-year four-item academic freedom index data
all data files that are necessary for running 1_academic_freedom_index_construction.R
-ert.csv: Episodes of Regime Transformation data (based on version V-Dem version 13)
-vdem13.rds: Varieties of Democracy data, version 13


#### Output results (relative path "~/results") ####
Store results (e.g. BFA estimates)

#### Output tables (relative path "~/tables") ####
Store tables

#### Output figures (relative path "~/figures") ####
Store figures


